package Q1;

import java.util.Scanner;

public class Main {

    public static long n;
    public static long m;
    public static long a;
    public static long b;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        n = scanner.nextLong(); //苹果
        m = scanner.nextLong(); //桃子
        a = scanner.nextLong(); //2 苹果 1 桃子
        b = scanner.nextLong(); //1 苹果 2 桃子

        System.out.println(Math.max(Math.max(method1(), method2()), method3()));
    }

    /**
     * 全为 2 苹果 1 桃子
     * @return
     */
    public static long method1() {
        long count1 = n / 2;
        long count2 = m;

        return a * Math.min(count1, count2);
    }

    /**
     * 全为 1 苹果 2 桃子
     */
    public static long method2() {
        long count1 = n;
        long count2 = m / 2;

        return b * Math.min(count1, count2);
    }

    /**
     * 部分方案一，部分方案二
     * @return
     */
    public static long method3() {
        long ret = 0;

        int count = 1; //方案一的个数

        long sum1 = 0; //方案一的金额
        long sum2 = 0; //方案二的金额
        while (true) {
            sum1 = count * a;

            //求出剩余的苹果、桃子数量
            long n2 = n - count * 2;
            long m2 = m - count;
            if (n2 <= 0 || m2 <= 0) {
                break;
            }
            sum2 = Math.min(n2, m2 / 2) * b;
            ret = Math.max(ret, sum1 + sum2);
            count++;
        }

        return ret;
    }
}
